package com.wonderful.eyepetizer.ui.pages.daily

import androidx.compose.runtime.mutableStateListOf
import androidx.compose.runtime.mutableStateOf
import androidx.lifecycle.viewModelScope
import androidx.paging.PagingData
import androidx.paging.cachedIn
import com.wonderful.eyepetizer.app.base.BaseViewModel
import com.wonderful.eyepetizer.data.entity.bean.Item
import com.wonderful.eyepetizer.data.repo.MainRepo
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.flow.Flow
import javax.inject.Inject

/**
 * Desc:
 * @Author: wonderful
 * @Time: 2024/1/23 16:44
 */
@HiltViewModel
class DailyViewModel @Inject constructor(private val mRepo: MainRepo) : BaseViewModel() {
    var bannerList = mutableStateListOf<Item>()

    var refreshing = mutableStateOf(false)

    val pageFlow = mRepo.getDaily(bannerList, refreshing).cachedIn(viewModelScope)

    fun getDaily(): Flow<PagingData<Item>> {
        return mRepo.getDaily(bannerList, refreshing).cachedIn(viewModelScope)
    }


}